package com.kurumi.medical.util;

import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class Html2ImageUtil {

	 protected static void generateOutput() throws Exception {  
         
	        //load the webpage into the editor  
	        //JEditorPane ed = new JEditorPane(new URL("http://www.google.com"));  
	        JEditorPane ed = new JEditorPane("ftp://132.147.0.167/MEDDOC/00/00/0A/10/09/IP_1/A1009_34130-17_20170301144301_1.html");  
	        ed.setSize(1000,800);  
	  
	        //create a new image  
	        BufferedImage image = new BufferedImage(ed.getWidth(), ed.getHeight(),  
	                                                BufferedImage.TYPE_INT_ARGB);  
	  
	        //paint the editor onto the image  
	        SwingUtilities.paintComponent(image.createGraphics(),   
	                                      ed,   
	                                      new JPanel(),   
	                                      0, 0, image.getWidth(), image.getHeight());  
	        //save the image to file  
	        ImageIO.write((RenderedImage)image, "png", new File("D://html.png"));  
	    }  
	  /*  public static void main(String[] args) {  
	        try {  
	            generateOutput();  
	        } catch (Exception e) {  
	            e.printStackTrace();  
	        }  
	    }  */
	    
	   
}
